﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace queue
{
    public class Chairs
    {
        private Queue _chairsA;

        public Queue ChairsA
        {
            get { return _chairsA; }
            set { _chairsA = value; }
        }
        private Queue _chairsB;

        public Chairs()
        {
            _chairsA = new Queue(20);
            _chairsB = new Queue(10);
        }
        public bool AddPerson(Person pers)
        {
            try
            {
                ChairsA.Enqueue(pers);
                return true;
            }
            catch (Exception exc)
            {
                return false;
            }
        }
        public Person RemovePerson()
        {
            try
            {
                return (Person)ChairsA.Dequeue();
            }
            catch (Exception exc)
            {
                return null;
            }
        }
        // 提供同步对对象的访问的机制。
        //System.Threading.Monitor 
        //Monitor.Enter(myObj);
        //Monitor.Exit(myObj);
    }
}
